home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / Power.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  10.5 KB  |  592 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Power.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__POWER__') = 'UNDEFINED' THEN
  18. __POWER__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__TYPES__') = 'UNDEFINED' THEN
  22.     include 'Types.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  27.     include 'MixedMode.a'
  28.     ENDIF
  29.  
  30. ; Bit positions for ModemByte 
  31. modemOnBit                        EQU        0
  32. ringWakeUpBit                    EQU        2
  33. modemInstalledBit                EQU        3
  34. ringDetectBit                    EQU        4
  35. modemOnHookBit                    EQU        5
  36. ; masks for ModemByte 
  37. modemOnMask                        EQU        $1
  38. ringWakeUpMask                    EQU        $4
  39. modemInstalledMask                EQU        $8
  40. ringDetectMask                    EQU        $10
  41. modemOnHookMask                    EQU        $20
  42. ; bit positions for BatteryByte 
  43. chargerConnBit                    EQU        0
  44. hiChargeBit                        EQU        1
  45. chargeOverFlowBit                EQU        2
  46. batteryDeadBit                    EQU        3
  47. batteryLowBit                    EQU        4
  48. connChangedBit                    EQU        5
  49. ; masks for BatteryByte 
  50. chargerConnMask                    EQU        $1
  51. hiChargeMask                    EQU        $2
  52. chargeOverFlowMask                EQU        $4
  53. batteryDeadMask                    EQU        $8
  54.  
  55. batteryLowMask                    EQU        $10
  56. connChangedMask                    EQU        $20
  57. ; commands to SleepQRec sleepQProc 
  58. sleepRequest                    EQU        1
  59. sleepDemand                        EQU        2
  60. sleepWakeUp                        EQU        3
  61. sleepRevoke                        EQU        4
  62. ; SleepQRec.sleepQFlags 
  63. noCalls                            EQU        1
  64. noRequest                        EQU        2
  65. slpQType                        EQU        16
  66. sleepQType                        EQU        16
  67.  
  68. ; bits in bitfield returned by PMFeatures 
  69. hasWakeupTimer                    EQU        0                    ; 1=wakeup timer is supported                        
  70. hasSharedModemPort                EQU        1                    ; 1=modem port shared by SCC and internal modem    
  71. hasProcessorCycling                EQU        2                    ; 1=processor cycling is supported                    
  72. mustProcessorCycle                EQU        3                    ; 1=processor cycling should not be turned off        
  73. hasReducedSpeed                    EQU        4                    ; 1=processor can be started up at reduced speed    
  74. dynamicSpeedChange                EQU        5                    ; 1=processor speed can be switched dynamically    
  75. hasSCSIDiskMode                    EQU        6                    ; 1=SCSI Disk Mode is supported                    
  76. canGetBatteryTime                EQU        7                    ; 1=battery time can be calculated                    
  77. canWakeupOnRing                    EQU        8                    ; 1=can wakeup when the modem detects a ring        
  78. hasDimmingSupport                EQU        9                    ; 1 has dimming support built into the rom            
  79.  
  80. ; bits in bitfield returned by GetIntModemInfo and set by SetIntModemState 
  81. hasInternalModem                EQU        0                    ; 1=internal modem installed                        
  82. intModemRingDetect                EQU        1                    ; 1=internal modem has detected a ring                
  83. intModemOffHook                    EQU        2                    ; 1=internal modem is off hook                        
  84. intModemRingWakeEnb                EQU        3                    ; 1=wakeup on ring is enabled                        
  85. extModemSelected                EQU        4                    ; 1=external modem selected                        
  86. modemSetBit                        EQU        15                    ; 1=set bit, 0=clear bit (SetIntModemState)        
  87.  
  88. ; bits in BatteryInfo.flags                                     
  89. ; ("chargerConnected" doesn't mean the charger is plugged in)    
  90. batteryInstalled                EQU        7                    ; 1=battery is currently connected                    
  91. batteryCharging                    EQU        6                    ; 1=battery is being charged                        
  92. chargerConnected                EQU        5                    ; 1=charger is connected to the PowerBook            
  93.  
  94. HDPwrQType                        EQU        'HD'
  95.  
  96. BatteryInfo             RECORD    0
  97. flags                     ds.b    1                                    ; misc flags (see below)                            
  98. warningLevel             ds.b    1                                    ; scaled warning level (0-255)                        
  99. reserved                 ds.b    1                                    ; reserved for internal use                        
  100. batteryLevel             ds.b    1                                    ; scaled battery level (0-255)                        
  101. sizeof                     EQU    4
  102.                         ENDR
  103.  
  104. HDQueueElement             RECORD    0
  105. hdQLink                     ds.l    1                                    ; pointer to next queue element                    
  106. hdQType                     ds.w    1                                    ; queue element type (must be HDQType)                
  107. hdFlags                     ds.w    1                                    ; miscellaneous flags                                
  108. hdProc                     ds.l    1                                    ; pointer to routine to call                        
  109. hdUser                     ds.l    1                                    ; user-defined (variable storage, etc.)            
  110. sizeof                     EQU    16
  111.                         ENDR
  112.  
  113. SleepQRec                 RECORD    0
  114. sleepQLink                 ds.l    1
  115. sleepQType                 ds.w    1                                    ; type = 16                            
  116. sleepQProc                 ds.l    1                                    ; Pointer to sleep universal proc ptr    
  117. sleepQFlags                 ds.w    1
  118. sizeof                     EQU    12
  119.                         ENDR
  120.  
  121. ; wakeup time record 
  122. WakeupTime                 RECORD    0
  123. wakeTime                 ds.l    1                                    ; wakeup time (same format as current time)        
  124. wakeEnabled                 ds.b    1                                    ; 1=enable wakeup timer, 0=disable wakeup timer    
  125. filler                     ds.b    1
  126. sizeof                     EQU    6
  127.                         ENDR
  128.  
  129. ; battery time information (in seconds) 
  130. BatteryTimeRec             RECORD    0
  131. expectedBatteryTime         ds.l    1                                    ; estimated battery time remaining                
  132. minimumBatteryTime         ds.l    1                                    ; minimum battery time remaining                
  133. maximumBatteryTime         ds.l    1                                    ; maximum battery time remaining                
  134. timeUntilCharged         ds.l    1                                    ; time until battery is fully charged            
  135. sizeof                     EQU    16
  136.                         ENDR
  137.  
  138.     IF GENERATING68K THEN
  139.         _IdleUpdate:    OPWORD    $A285
  140.     ELSE
  141.         IMPORT    IdleUpdate
  142.     ENDIF
  143.  
  144.     IF GENERATING68K THEN
  145.         Macro
  146.         _GetCPUSpeed
  147.             dc.w     $70FF
  148.             dc.w     $A485
  149.         EndM
  150.     ELSE
  151.         IMPORT    GetCPUSpeed
  152.     ENDIF
  153.  
  154.     IF GENERATING68K THEN
  155.         Macro
  156.         _EnableIdle
  157.             moveq    #0,d0
  158.             dc.w     $A485
  159.         EndM
  160.     ELSE
  161.         IMPORT    EnableIdle
  162.     ENDIF
  163.  
  164.     IF GENERATING68K THEN
  165.         Macro
  166.         _DisableIdle
  167.             moveq    #1,d0
  168.             dc.w     $A485
  169.         EndM
  170.     ELSE
  171.         IMPORT    DisableIdle
  172.     ENDIF
  173.  
  174.     IF GENERATING68K THEN
  175.         _SleepQInstall:    OPWORD    $A28A
  176.     ELSE
  177.         IMPORT    SleepQInstall
  178.     ENDIF
  179.  
  180.     IF GENERATING68K THEN
  181.         _SleepQRemove:    OPWORD    $A48A
  182.     ELSE
  183.         IMPORT    SleepQRemove
  184.     ENDIF
  185.  
  186.     IF GENERATING68K THEN
  187.         Macro
  188.         _AOn
  189.             moveq    #4,d0
  190.             dc.w     $A685
  191.         EndM
  192.     ELSE
  193.         IMPORT    AOn
  194.     ENDIF
  195.  
  196.     IF GENERATING68K THEN
  197.         Macro
  198.         _AOnIgnoreModem
  199.             moveq    #5,d0
  200.             dc.w     $A685
  201.         EndM
  202.     ELSE
  203.         IMPORT    AOnIgnoreModem
  204.     ENDIF
  205.  
  206.     IF GENERATING68K THEN
  207.         Macro
  208.         _BOn
  209.             moveq    #0,d0
  210.             dc.w     $A685
  211.         EndM
  212.     ELSE
  213.         IMPORT    BOn
  214.     ENDIF
  215.  
  216.     IF GENERATING68K THEN
  217.         Macro
  218.         _AOff
  219.             dc.w     $7084
  220.             dc.w     $A685
  221.         EndM
  222.     ELSE
  223.         IMPORT    AOff
  224.     ENDIF
  225.  
  226.     IF GENERATING68K THEN
  227.         Macro
  228.         _BOff
  229.             dc.w     $7080
  230.             dc.w     $A685
  231.         EndM
  232.     ELSE
  233.         IMPORT    BOff
  234.     ENDIF
  235.  
  236. ; Public Power Management API (NEW!) 
  237.     IF GENERATING68K THEN
  238.         Macro
  239.         _PMSelectorCount
  240.             moveq    #0,d0
  241.             dc.w     $A09E
  242.         EndM
  243.     ELSE
  244.         IMPORT    PMSelectorCount
  245.     ENDIF
  246.  
  247.     IF GENERATING68K THEN
  248.         Macro
  249.         _PMFeatures
  250.             moveq    #1,d0
  251.             dc.w     $A09E
  252.         EndM
  253.     ELSE
  254.         IMPORT    PMFeatures
  255.     ENDIF
  256.  
  257.     IF GENERATING68K THEN
  258.         Macro
  259.         _GetSleepTimeout
  260.             moveq    #2,d0
  261.             dc.w     $A09E
  262.         EndM
  263.     ELSE
  264.         IMPORT    GetSleepTimeout
  265.     ENDIF
  266.  
  267.     IF GENERATING68K THEN
  268.         Macro
  269.         _SetSleepTimeout
  270.             dc.w     $4840
  271.             move.w    #$0003,d0
  272.             dc.w     $A09E
  273.         EndM
  274.     ELSE
  275.         IMPORT    SetSleepTimeout
  276.     ENDIF
  277.  
  278.     IF GENERATING68K THEN
  279.         Macro
  280.         _GetHardDiskTimeout
  281.             moveq    #4,d0
  282.             dc.w     $A09E
  283.         EndM
  284.     ELSE
  285.         IMPORT    GetHardDiskTimeout
  286.     ENDIF
  287.  
  288.     IF GENERATING68K THEN
  289.         Macro
  290.         _SetHardDiskTimeout
  291.             dc.w     $4840
  292.             move.w    #$0005,d0
  293.             dc.w     $A09E
  294.         EndM
  295.     ELSE
  296.         IMPORT    SetHardDiskTimeout
  297.     ENDIF
  298.  
  299.     IF GENERATING68K THEN
  300.         Macro
  301.         _HardDiskPowered
  302.             moveq    #6,d0
  303.             dc.w     $A09E
  304.         EndM
  305.     ELSE
  306.         IMPORT    HardDiskPowered
  307.     ENDIF
  308.  
  309.     IF GENERATING68K THEN
  310.         Macro
  311.         _SpinDownHardDisk
  312.             moveq    #7,d0
  313.             dc.w     $A09E
  314.         EndM
  315.     ELSE
  316.         IMPORT    SpinDownHardDisk
  317.     ENDIF
  318.  
  319.     IF GENERATING68K THEN
  320.         Macro
  321.         _IsSpindownDisabled
  322.             moveq    #8,d0
  323.             dc.w     $A09E
  324.         EndM
  325.     ELSE
  326.         IMPORT    IsSpindownDisabled
  327.     ENDIF
  328.  
  329.     IF GENERATING68K THEN
  330.         Macro
  331.         _SetSpindownDisable
  332.             dc.w     $4840
  333.             move.w    #$0009,d0
  334.             dc.w     $A09E
  335.         EndM
  336.     ELSE
  337.         IMPORT    SetSpindownDisable
  338.     ENDIF
  339.  
  340.     IF GENERATING68K THEN
  341.         Macro
  342.         _HardDiskQInstall
  343.             moveq    #10,d0
  344.             dc.w     $A09E
  345.         EndM
  346.     ELSE
  347.         IMPORT    HardDiskQInstall
  348.     ENDIF
  349.  
  350.     IF GENERATING68K THEN
  351.         Macro
  352.         _HardDiskQRemove
  353.             moveq    #11,d0
  354.             dc.w     $A09E
  355.         EndM
  356.     ELSE
  357.         IMPORT    HardDiskQRemove
  358.     ENDIF
  359.  
  360.     IF GENERATING68K THEN
  361.         Macro
  362.         _GetScaledBatteryInfo
  363.             dc.w     $4840
  364.             move.w    #$000C,d0
  365.             dc.w     $A09E
  366.             dc.w     $2080
  367.         EndM
  368.     ELSE
  369.         IMPORT    GetScaledBatteryInfo
  370.     ENDIF
  371.  
  372.     IF GENERATING68K THEN
  373.         Macro
  374.         _AutoSleepControl
  375.             dc.w     $4840
  376.             move.w    #$000D,d0
  377.             dc.w     $A09E
  378.         EndM
  379.     ELSE
  380.         IMPORT    AutoSleepControl
  381.     ENDIF
  382.  
  383.     IF GENERATING68K THEN
  384.         Macro
  385.         _GetIntModemInfo
  386.             moveq    #14,d0
  387.             dc.w     $A09E
  388.         EndM
  389.     ELSE
  390.         IMPORT    GetIntModemInfo
  391.     ENDIF
  392.  
  393.     IF GENERATING68K THEN
  394.         Macro
  395.         _SetIntModemState
  396.             dc.w     $4840
  397.             move.w    #$000F,d0
  398.             dc.w     $A09E
  399.         EndM
  400.     ELSE
  401.         IMPORT    SetIntModemState
  402.     ENDIF
  403.  
  404.     IF GENERATING68K THEN
  405.         Macro
  406.         _MaximumProcessorSpeed
  407.             moveq    #16,d0
  408.             dc.w     $A09E
  409.         EndM
  410.     ELSE
  411.         IMPORT    MaximumProcessorSpeed
  412.     ENDIF
  413.  
  414.     IF GENERATING68K THEN
  415.         Macro
  416.         _CurrentProcessorSpeed
  417.             moveq    #17,d0
  418.             dc.w     $A09E
  419.         EndM
  420.     ELSE
  421.         IMPORT    CurrentProcessorSpeed
  422.     ENDIF
  423.  
  424.     IF GENERATING68K THEN
  425.         Macro
  426.         _FullProcessorSpeed
  427.             moveq    #18,d0
  428.             dc.w     $A09E
  429.         EndM
  430.     ELSE
  431.         IMPORT    FullProcessorSpeed
  432.     ENDIF
  433.  
  434.     IF GENERATING68K THEN
  435.         Macro
  436.         _SetProcessorSpeed
  437.             dc.w     $4840
  438.             move.w    #$0013,d0
  439.             dc.w     $A09E
  440.         EndM
  441.     ELSE
  442.         IMPORT    SetProcessorSpeed
  443.     ENDIF
  444.  
  445.     IF GENERATING68K THEN
  446.         Macro
  447.         _GetSCSIDiskModeAddress
  448.             moveq    #20,d0
  449.             dc.w     $A09E
  450.         EndM
  451.     ELSE
  452.         IMPORT    GetSCSIDiskModeAddress
  453.     ENDIF
  454.  
  455.     IF GENERATING68K THEN
  456.         Macro
  457.         _SetSCSIDiskModeAddress
  458.             dc.w     $4840
  459.             move.w    #$0015,d0
  460.             dc.w     $A09E
  461.         EndM
  462.     ELSE
  463.         IMPORT    SetSCSIDiskModeAddress
  464.     ENDIF
  465.  
  466.     IF GENERATING68K THEN
  467.         Macro
  468.         _GetWakeupTimer
  469.             moveq    #22,d0
  470.             dc.w     $A09E
  471.         EndM
  472.     ELSE
  473.         IMPORT    GetWakeupTimer
  474.     ENDIF
  475.  
  476.     IF GENERATING68K THEN
  477.         Macro
  478.         _SetWakeupTimer
  479.             moveq    #23,d0
  480.             dc.w     $A09E
  481.         EndM
  482.     ELSE
  483.         IMPORT    SetWakeupTimer
  484.     ENDIF
  485.  
  486.     IF GENERATING68K THEN
  487.         Macro
  488.         _IsProcessorCyclingEnabled
  489.             moveq    #24,d0
  490.             dc.w     $A09E
  491.         EndM
  492.     ELSE
  493.         IMPORT    IsProcessorCyclingEnabled
  494.     ENDIF
  495.  
  496.     IF GENERATING68K THEN
  497.         Macro
  498.         _EnableProcessorCycling
  499.             dc.w     $4840
  500.             move.w    #$0019,d0
  501.             dc.w     $A09E
  502.         EndM
  503.     ELSE
  504.         IMPORT    EnableProcessorCycling
  505.     ENDIF
  506.  
  507.     IF GENERATING68K THEN
  508.         Macro
  509.         _BatteryCount
  510.             moveq    #26,d0
  511.             dc.w     $A09E
  512.         EndM
  513.     ELSE
  514.         IMPORT    BatteryCount
  515.     ENDIF
  516.  
  517.     IF GENERATING68K THEN
  518.         Macro
  519.         _GetBatteryVoltage
  520.             dc.w     $4840
  521.             move.w    #$001B,d0
  522.             dc.w     $A09E
  523.         EndM
  524.     ELSE
  525.         IMPORT    GetBatteryVoltage
  526.     ENDIF
  527.  
  528.     IF GENERATING68K THEN
  529.         Macro
  530.         _GetBatteryTimes
  531.             dc.w     $4840
  532.             move.w    #$001C,d0
  533.             dc.w     $A09E
  534.         EndM
  535.     ELSE
  536.         IMPORT    GetBatteryTimes
  537.     ENDIF
  538.  
  539.     IF GENERATING68K THEN
  540.         Macro
  541.         _GetDimmingTimeout
  542.             moveq    #29,d0
  543.             dc.w     $A09E
  544.         EndM
  545.     ELSE
  546.         IMPORT    GetDimmingTimeout
  547.     ENDIF
  548.  
  549.     IF GENERATING68K THEN
  550.         Macro
  551.         _SetDimmingTimeout
  552.             dc.w     $4840
  553.             move.w    #$001E,d0
  554.             dc.w     $A09E
  555.         EndM
  556.     ELSE
  557.         IMPORT    SetDimmingTimeout
  558.     ENDIF
  559.  
  560.     IF GENERATING68K THEN
  561.         Macro
  562.         _DimmingControl
  563.             dc.w     $4840
  564.             move.w    #$001F,d0
  565.             dc.w     $A09E
  566.         EndM
  567.     ELSE
  568.         IMPORT    DimmingControl
  569.     ENDIF
  570.  
  571.     IF GENERATING68K THEN
  572.         Macro
  573.         _IsDimmingControlDisabled
  574.             moveq    #32,d0
  575.             dc.w     $A09E
  576.         EndM
  577.     ELSE
  578.         IMPORT    IsDimmingControlDisabled
  579.     ENDIF
  580.  
  581.     IF GENERATING68K THEN
  582.         Macro
  583.         _IsAutoSlpControlDisabled
  584.             moveq    #33,d0
  585.             dc.w     $A09E
  586.         EndM
  587.     ELSE
  588.         IMPORT    IsAutoSlpControlDisabled
  589.     ENDIF
  590.  
  591.     ENDIF ; __POWER__
  592.